<?php

declare(strict_types=1);

namespace app\admin\controller;

use app\common\facade\Builder;
//该文件为自动生成，请按需修改
class FootPrint extends Base
{
    //所有定义变量均为演示，请根据实际需求更改

    //主键，默认为id
    protected string $pk = 'id';

    //主模型
    protected string $model = '\app\common\model\Footprint';

    //关联模型
    protected array $hasOne = ['user'];

    //附加字段或者虚拟字段
    protected array $append = [];
    protected int $takeOver = 3;
    public function index(): string
    {
        $param = $this->request->get();
        $map = [];
        if (!empty($param['id'])) {
            $map['uid__uid'] = $param['id'];
        }
        //构建表格数据
        return Builder::Table()
            ->addColumn(['type' => 'checkbox', 'title' => '全选', 'fixed' => 'left'])
            ->addColumn(['field' => 'id', 'sort' => true, 'title' => 'ID', 'width' => 80])
            ->addColumn(['field' => 'code', 'title' => '浏览会员', 'templet' => '#_userTpl', 'width' => 250])
            ->addColumn(['field' => 'mobile', 'title' => '手机号', 'templet' => '<div>{{- d.user.mobile}}</div>', 'width' => 250])
            ->addColumn(['field' => 'product', 'title' => '浏览商品', 'templet' => '<div>{{- d.product}}</div>', 'width' => 300])
            ->addColumn(['field' => 'create_time', 'title' => '浏览时间'])
            ->addSearch([
                ['uid', '会员编号/昵称/手机号', 'input', '', '\app\common\model\User', 'code|nickname|mobile,id'],
            ])
            ->addSortTool([['name' => 'sort', 'pk' => $this->pk, 'url' => url('update')->build()]])
            ->addExtraMap($map)
            ->fetch();
    }
}
